package market.impl;

import market.SaleProxy;

import java.math.BigDecimal;

/**
 * 100 - 10 策略
 */
public class OneHundredMinusTenSaleProxy implements SaleProxy {
    private static final BigDecimal PROMOTION_THRESHOLD = new BigDecimal("100"); // 满减门槛
    private static final BigDecimal PROMOTION_DISCOUNT = new BigDecimal("10");   // 满减金额
    @Override
    public BigDecimal getAfterSalePrice(BigDecimal price) {
        // 检查价格是否满足满减条件
        System.out.printf("金额:%s元 ", price.doubleValue());
        if (price.compareTo(PROMOTION_THRESHOLD) >= 0) {
            // 满足条件，减去 10 元
            System.out.println("达到100元，扣减金额10元");
            return price.subtract(PROMOTION_DISCOUNT);
        } else {
            System.out.println("未达到金额，返回原价");
            // 不满足条件，返回原价
            return price;
        }
    }
}
